package wxk.study.springtx.util;

import java.util.Random;
import java.util.UUID;

/**
 * @author wangxuekai
 * @version 2.2
 * @Date 2017/3/15.
 * @since 2.2
 */
public class IdGenerator {

    private static String[] PRE = {"131","150"};
    private static String[] MID = {"0210","0543"};
    private static int[] NUM = {0,1,2,3,4,5,6,7,8,9};
    private static Random random = new Random();

    public static String genUUID(){
        return UUID.randomUUID().toString().replaceAll("-","");
    }

    public static String genMobile(){
        StringBuilder stringBuilder  = new StringBuilder(13);
        stringBuilder.append(PRE[random.nextInt(PRE.length)]).append(MID[random.nextInt(MID.length)]).append(genNum(4));
        return stringBuilder.toString();
    }

    public static String genNum(int num){
       StringBuilder stringBuilder = new StringBuilder(num);

       for (int i = 0;i < num; i++){
           stringBuilder.append(NUM[random.nextInt(10)]);
       }

       return stringBuilder.toString();
    }

    public static void main(String[] args){
        System.out.println(genMobile());
    }
}
